<%-- 
    Document   : viewTest
    Created on : Nov 4, 2009, 2:41:42 PM
    Author     : khanhlv_b00554
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" import="java.sql.*,DAO.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%
    Test check = new Test();
    String txtSubSubject = request.getParameter("txtSubSubject");
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" media="screen" href="css/admin.css">
        <title>JSP Page</title>
        <script language="javascript">
            function addTest(){
                window.location = "addTest.jsp?txtSubSubject="+<%=txtSubSubject%>;
            }
        </script>
    </head>
    <body>
        <fieldset class="testView">
            <form action="" method="get" name="myForm">
            <span class="textSpanTitle">Test Content Question</span>
            <br />
            <table width="700" border="1" class="sample" align="center">
                <tr>
                    <td>
                        <select name="txtSubSubject" >
                                <option value="0">Select Subject</option>
                                <%
                                    ResultSet subject = check.viewSubSubject();
                                    while(subject.next()) {
                                %>
                                <option value="<%=subject.getString("SubID")%>" <% if(subject.getString("SubID").equals(txtSubSubject)) { %> selected="true" <% } %>><%=subject.getString("SubName")%></option>
                                <% } %>
                         </select>
                        <input type="submit" value="View  Test" class="button" />
                        <input type="button" value="Add Test" class="button" onclick="addTest()" />
                    </td>
                </tr>
            </table>
            
            <table width="700" border="1" class="sample" align="center">
                <thead>
                    <tr>
                        <th width="25">ID</th>
                        <th width="250">TestName</th>
                        <th width="50">TestTime</th>
                        <th width="100">SubSubject</th>
                        <th width="120">Status</th>
                        <th width="50">Edit</th>
                        <th width="50">Delete</th>
                    </tr>
                </thead>
                <%
                    ResultSet rs = check.viewTestID(txtSubSubject);
                    ResultSet rsNoFound = check.viewTestID(txtSubSubject);
                    int i=0;
                    while(rs.next())
                    {
                %>
                <tbody>
                    <tr>
                        <td width="25"><%=i%></td>
                        <td width="250"><%=rs.getString("TestName")%></td>
                        <td width="50"><%=rs.getString("TestTime")%></td>
                        <td width="100"><%=rs.getString("SubName")%></td>
                        <td width="120">
                            <%
                            if (rs.getBoolean("Status") == true) {
                        %>
                        <span style="color:red">Đang hoạt động</span>
                        <% } else {
                        %>
                        <span style="color:green">Ngừng họat động </span>
                        <% }%>
                        </td>
                        <td width="50"><a href="checkUpdateTest.jsp?id=<%=rs.getString("TestID")%>&txtSubSubject=<%=rs.getString("SubID")%>"><span  class="textSpan">Edit</span></a></td>
                        <td width="50"><a href="deleteTest.jsp?id=<%=rs.getString("TestID")%>&txtSubSubject=<%=rs.getString("SubID")%>"><span  class="textSpan">Delete</span></td>
                    </tr>
                </tbody>
                <%
                    i++;
                    }
                %>
            </table>
            <table width="700" border="1" class="sample" align="center">
                <tr>
                    <td>
                        <%
                            if(!rsNoFound.next()) {
                        %>
                        <span class="textSpan">Không có bản ghi nào trong Database</span>
                        <% } %>
                    </td>
                </tr>
            </table>
            <br />
            </form>
        </fieldset>
    </body>
</html>
